package com.example.demo.practice.tool;

import android.content.Context;
import android.content.res.TypedArray;

/**
 * Created by hanbo on 2017-12-05.
 */

public class ImageGroupID {
    private Context context;

    public ImageGroupID(Context context) {
        super();
        this.context=context;
    }

    /**
     * 将照片字符数组转换为ID数组
     * @param arrayId 字符数组ID
     * @return 照片ID数组
     */
    public int[] getImageGroupID(int arrayId){
        TypedArray ar = context.getResources().obtainTypedArray(arrayId);
        int len = ar.length();
        int[] resIds = new int[len];
        for (int i = 0; i < len; i++)
            resIds[i] = ar.getResourceId(i, 0);
        ar.recycle();
        return resIds;
    }
}
